﻿//-----------------------------------------------------------------------
// <copyright file="ChooseSource.cs" company="Sondre Bjellås">
// This software is licensed as Microsoft Public License (Ms-PL).
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Drawing;
using System.Windows.Forms;
using FlickrDownloadr.Services;

namespace FlickrDownloadr
{
    public delegate void NextDelegate(UserControl source, bool refresh);

    public partial class ChooseSource : UserControl, IWizardPage
    {
        public void ReloadPage()
        { }

        public ChooseSource()
        {
            InitializeComponent();
        }

        public string Title
        {
            get { return Properties.Resources.PageSourceTitle; }
        }

        public string Description
        {
            get { return Properties.Resources.PageSourceDescription; }
        }

        public event NextDelegate Next;

        public void OnNext(SourceOptions selectedOption)
        {
            PhotoService.Instance.Reset();

            switch (selectedOption)
            {
                case SourceOptions.Group:
                    PhotoService.Instance.SearchOptions.Type = SearchType.Group;
                    break;
                case SourceOptions.Search:
                    PhotoService.Instance.SearchOptions.Type = SearchType.Search;
                    break;
                case SourceOptions.User:
                    //PhotoService.Instance.SearchOptions.Type = SearchType.Use
                    //PhotoService.Instance.SearchOptions.Type = SearchType.Selection;
                    break;
            }

            PhotoService.Instance.SearchOptions.Source = selectedOption;

            if (Next != null)
                Next(this, false);
        }

        public Bitmap Icon
        {
            get { return Properties.Resources._1403_Globe; }
        }

        private void CommandLink1_Click(object sender, EventArgs e)
        {
            OnNext(SourceOptions.User);
        }

        private void CommandLink2_Click(object sender, EventArgs e)
        {
            OnNext(SourceOptions.Group);
        }

        private void CommandLink3_Click(object sender, EventArgs e)
        {
            OnNext(SourceOptions.Search);
        }

    }
}
